import cn.yunhe.entity.*;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class Demo {
    ApplicationContext app = null;

    @Before
    public void before() {
        app = new ClassPathXmlApplicationContext("applicationContext.xml");
    }

    @Test
    public void test1() {
        MainFrame m = (MainFrame) app.getBean("mainFrame");
        m.mainInfo();
    }

    @Test
    public void test2() {
        Computer com = (Computer) app.getBean("computer");
        com.computerInfo();
    }

    @Test
    public void printTest() {
        Printer printer = (Printer) app.getBean("printer");
        printer.printInfo();
    }

    @Test
    public void deptTest() {
        Dept dept = app.getBean("dept", Dept.class);
        List<Emplo> list = dept.getEmpList();
        for (Emplo e : list) {
            System.out.println("部门:" + dept.getDname() + ",员工:" + e.getEname() + ",员工住址:" + e.getEaddr());
        }
    }
}
